package com.cxb.apipassenger.service;

import com.cxb.apipassenger.remote.ServicePassengerUserClient;
import com.cxb.internalcommon.dto.PassengerUser;
import com.cxb.internalcommon.dto.ResponseResult;
import com.cxb.internalcommon.request.VerificationCodeDTO;
import com.cxb.internalcommon.util.JwtUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import javax.xml.ws.Response;
import java.awt.print.PrinterJob;

@Service
@Slf4j
public class UserService {

    @Autowired
    ServicePassengerUserClient servicePassengerUserClient;

    public ResponseResult getUserByAccessToken(String accessToken){
        log.info("accessToken:"+accessToken);

        //解析accessToken,拿到手机号
        String phone = JwtUtils.checkToken(accessToken).getPhone();
        log.info("phone"+phone);

        //根据手机号查询用户信息
        //调用service-passenger-user服务

        ResponseResult<PassengerUser> userByPhone = servicePassengerUserClient.getUserByPhone(phone);

        return ResponseResult.success(userByPhone.getData());
    }



}
